import Common from "../../Common/common";





export default class Resurrection extends Laya.Dialog {
    [x: string]: any;
    type:number

    constructor() {
        super()
    }

    /**
     * 监听打开场景
     */
    onOpened(args){
        this.type = args
        this.btnEvent()
    }

    /**
     * 按钮监听
     */
    btnEvent(){
        Laya.stage.once("resurrection",this,this.resurrection)
        this.continue.on(Laya.Event.CLICK,this,this.watchVideo);
        this.skip.once(Laya.Event.CLICK,this,this.goGameOver)
    } 

    /**
     * 跳过
     */
    goGameOver(){
        Laya.stage.event("playSound",["sound/tap.mp3"])
        Laya.stage.event("isDouble")
        this.close()
    }

    /**
     * 看视频复活
     */
    watchVideo(){
        Laya.stage.event("playSound",["sound/tap.mp3"])
        Common.lastRewardedVideoEventName = "resurrection"
        Laya.stage.event("showRewardedShortVideoAd")
        
    }

    resurrection(){
        this.close()
        console.log(this.type)
        if(this.type == 1){
            Laya.stage.event("resurrectionTween")
        }else{
            Laya.stage.event("newlyAdded")
        }
    }

    onClosed(){
        console.log("执行了关闭");
        this.continue.off(Laya.Event.CLICK,this,this.watchVideo);
    }
}